$(function (){
    $("#name").blur(function (){
        let name = $("#name").val();
        if(name.length==0){
            $("#check_name").text("用户名不能为空");
            $("#check_name").css("color","#bb0707");
        }else{
            $("#check_name").text("");
            $.ajax({
                url: "/checkName",
                method: "post",
                data: {
                    "name": name
                },
                success: function (msg) {
                    $("#check_name").text(msg);
                    $("#check_name").css("color","#bb0707");
                }
            })
        }

    })

    $("#password").blur(function(){
        let pwd = $("#password").val();
        if(pwd.length<6 || pwd.length>12){
            $("#check_password_form").text("请填写6到12位密码");
            $("#check_password_form").css("color","#bb0707");
        }else{
            $("#check_password_form").text("");
        }
    })

    $("#register").click(function (){
        let pwd1 = $("#password").val();
        let pwd2 = $("#check_password").val();
        if(pwd1!=pwd2){
            $("#check_password_same").text("两次密码不一致");
            $("#check_password_same").css("color","#bb0707");
            return false;
        }
        return true;
    })


})
